﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using CSA.Lib;

namespace CSA.TSPProblem
{
    public partial class TSPCustomEncodeUI : CSCustomUI
    {
        CSTSPProblem m_Problem;

        public override CSAlgorithmSettings AlgorithmSettings
        {
            get
            {
                return base.AlgorithmSettings;
            }
            set
            {
                base.AlgorithmSettings = value;
                if (AlgorithmSettings == null)
                {
                    m_Problem = null;
                    txtPath.Text = "";
                    return;
                }
                m_Problem =(CSTSPProblem) AlgorithmSettings.SpatialOptimizationProblem;
                if (m_Problem != null)
                {
                    txtPath.DataBindings.Clear();                  
                    txtPath.DataBindings.Add("Text", m_Problem, "CityFile");              
                }                
            }
        }

        public CSTSPProblem ProblemInfo
        {
            get { return m_Problem; }          
        }
        public TSPCustomEncodeUI()
        {
            InitializeComponent();
        }
     

        private void txtPath_TextChanged(object sender, EventArgs e)
        {
            try
            {
       
            }
            catch
            { }
        }

        private void btnSelectCityFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "ESRI ShapeFile|*.shp";
            dlg.Title = "Open File";
            dlg.Multiselect = false;
            DialogResult re = dlg.ShowDialog();
            if (re == System.Windows.Forms.DialogResult.OK)
            {
                txtPath.Text = dlg.FileName;
                txtPath.Focus();
            }
        }
  
        private void CustomEncodeUI_Load(object sender, EventArgs e)
        {
            txtMemo.Text = global::CSA.TSPProblem.TextString.EncodeDes;
        }



    }
}
